import com.alibaba.fastjson.JSONObject;
import com.sun.org.apache.xpath.internal.operations.Mult;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.Transaction;

public class testString {

    public static void main(String[] args) {
        Jedis jedis = new Jedis();


        JSONObject jsonObject = new JSONObject();
        jsonObject.put("name","zhangsan");
        jsonObject.put("age",16);
        String s = jsonObject.toJSONString();

        //开启事务

        Transaction multi = jedis.multi();
        try {
            multi.set("user1",s);
            multi.set("user2",s);

            multi.exec(); //关闭事务
        } catch (Exception e) {
            multi.discard(); //放弃事务
        }finally {
            System.out.println(jedis.get("user1"));
            System.out.println(jedis.get("user2"));
        }
        jedis.close();
    }
}
